﻿using System;
using System.Data;
using System.Data.Common;
using System.Collections.Generic;
namespace Database
{
    public interface IDatabase : IDisposable
    {
        string DbName { get; set; }
        /// <summary>
        /// 数据驱动连接字符串
        /// </summary>
        string ConnString { get; set; }
        /// <summary>
        /// 数据源实例
        /// </summary>
        DbProviderFactory dbProviderFactory { get; set; }

        void OpenConnection();
        void CloseConnection();

        //DbTransaction Transaction { get; }
        void BeginTransaction();
        void EndTranscation(TransactionOptions TransOpt);

        DbParameter AddParameter(string ParameterName, DbType dbType, object Value);
        DbParameter AddParameter(string ParameterName, DbType dbType, object Value, int Size, ParameterDirection Direction, string SourceColumn, DataRowVersion SourceVersion);
        /// <summary>
        /// 对连接对象执行SQL语句
        /// </summary>
        /// <param name="QueryText"></param>
        /// <returns></returns>
        int ExceuteNonQuery(string QueryText);
        /// <summary>
        /// 对连接对象执行SQL语句
        /// </summary>
        /// <param name="QueryText"></param>
        /// <param name="dbParameters"></param>
        /// <returns></returns>
        int ExceuteNonQuery(string QueryText, IList<DbParameter> dbParameters);

        IDataReader ExceuteReader(string QueryText);
        IDataReader ExceuteReader(string QueryText, IList<DbParameter> dbParameters);

        object ExceuteScalar(string QueryText);
        object ExceuteScalar(string QueryText, IList<DbParameter> dbParameters);

        //void Dispose();
    }
}
